package com.mediocre.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.http.HttpStatus;

import java.io.Serializable;

//@ApiModel(value = "响应结果DTO", description = "响应结果数据传输对象")
@ApiModel(description = "响应结果数据传输对象")
@Data
@AllArgsConstructor
public class ResultDTO<T> implements Serializable {
    private static final long serialVersionUID = 1;
    @ApiModelProperty(value = "响应码", notes = "返回前端的提示编码")
    private Integer code;
    @ApiModelProperty(value = "响应消息", notes = "返回前端的提示消息")
    private String message;
    @ApiModelProperty(value = "响应数据", notes = "返回前端的具体数据")
    private T data;

    public ResultDTO(T data) {
        this.code = HttpStatus.OK.value();
        this.message = HttpStatus.OK.getReasonPhrase();
        this.data = data;
    }

    public ResultDTO() {
        this.code = HttpStatus.OK.value();
        this.message = HttpStatus.OK.getReasonPhrase();
    }
}